﻿using Sustainalytics.ClientDW.Synchronization.SyncESGData.AbstractClassesAndInterfaces;
using Sustainalytics.SharedEntities.EsgResearch;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Sustainalytics.ClientDW.Synchronization.SyncESGData.AnalystLogic
{
    public class AnalystOrchestrator : IComprehensiveEsgSyncOrchestrator<Analyst>
    {
        private readonly AnalystCommand analystCommand;
        private readonly IComprehensiveEsgAnalystQuery analystQuery;

        public AnalystOrchestrator(AnalystQuery analystQuery, AnalystCommand analystCommand)
        {
            this.analystQuery = analystQuery;
            this.analystCommand = analystCommand;
        }

        async Task IComprehensiveEsgSyncOrchestrator<Analyst>.OrchestrateAsync(IList<Analyst> comprehensiveEsgEntities, IList<Guid> invalidatedCompaniesIds)
        {
            await analystCommand.ExecuteAsync(comprehensiveEsgEntities ?? analystQuery.Get());
        }
    }
}
